package com.jumper.study.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

import com.jumper.study.common.util.AdminUtil;
import com.jumper.study.common.util.CaptchaUtil;
import com.jumper.study.common.util.JwtTokenUtil;
import com.jumper.study.component.JwtAuthenticationTokenFilter;
import com.jumper.study.component.StudyDenieHandler;
import com.jumper.study.component.StudyEntryPoint;

//开启缓存
//开启在当前类获取自身代理类
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
public class CommonSecurityConfig {
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    @Bean
    public JwtTokenUtil jwtTokenUtil() {
        return new JwtTokenUtil();
    }

    @Bean
    public JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter() {
        return new JwtAuthenticationTokenFilter();
    }

    @Bean
    public StudyEntryPoint studyEntryPoint() {
        return new StudyEntryPoint();
    }

    @Bean
    public StudyDenieHandler studyDenieHandler() {
        return new StudyDenieHandler();
    }

    @Bean
    public CaptchaUtil captchaUtil() {
        return new CaptchaUtil();
    }

    @Bean 
    public AdminUtil adminUtil() {
        return new AdminUtil();
    }
}
